<!DOCTYPE html>
<html lang="zh-cn">
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="Zhou Wei <zromyk@163.com>">
  <title>数学-高等数学 7 第16讲 无穷级数</title>
  <link rel="shortcut icon" href="/favicon.ico">
  <link rel="stylesheet" href="/style/html/pure.css">
  <link rel="stylesheet" href="/style/html/main.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
  <!-- <link rel="stylesheet" href="https://apps.bdimg.com/libs/highlight.js/9.1.0/styles/default.min.css"> -->
<link rel="stylesheet" href="/style/article/highlight/default.min.css">
<link rel="stylesheet" href="/style/article/pell-1.0.6/dist/pell.css">

</head>
<body>
  <div id="menu-background"></div>
  <div id="menu">
    <div class="pure-menu pure-menu-horizontal">
  <ul class="pure-menu-list block-middle">
    <li class="pure-menu-item">
  <a class="pure-menu-heading" href="/index.html">ZROMYK</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/index.html">主页</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/archive/index.html">归档</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/download/index.html">下载</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/feedback/index.html">反馈</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/about/index.html">关于我</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="https://github.com/zromyk"><i class="fa fa-github" style="font-size:32px"></i></a>
</li>

  </ul>
</div>

  </div>
  <div id="layout">
    <div class="content">
      <div id="nav">
    <div id="navigation" class="navigation">
  <ul class="pure-menu-list">
    <li class="pure-menu-item">
  <a class="pure-menu-link nav2" onclick="animateByNav()" href="#16">第16讲 无穷级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#1">1. 函数的正弦级数与余弦级展开</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#2">2. 数项级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#1_1">（1）正向级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#1_2">1、比较判别法</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#2_1">2、比值判别法（达朗贝尔）</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#3">3、根植判别式（柯西）</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#2_2">（2）交错级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#3_1">（3）任意级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#4">（4）条件收敛</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#3_2">3. 幂级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#1_3">（1）收敛半径、收敛区间、收敛域的关系</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#2_3">（2）收敛半径</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#2_4">2、缺项幂级数的收敛半径</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav4" onclick="animateByNav()" href="#3_3">（3）阿贝尔定理</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav3" onclick="animateByNav()" href="#4_1">4. 展开</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#1_4">1、直接计算或带入泰勒级数</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link nav5" onclick="animateByNav()" href="#2_5">2、用先积后导或先导后积的方法</a>
</li>

  </ul>
</div>

</div>
<div id="content-articles">
  <h1 id="数学-高等数学 7 第16讲 无穷级数" class="content-subhead">数学-高等数学 7 第16讲 无穷级数</h1>
  <p>
    <span>1970-01-01</span>
    <span><span class="post-category post-category-math">Math</span></span>
    <button id="button-markdownEditor" class="pure-button" onclick="markdownEditor()">启用编辑</button>
    <button id="button-save" class="pure-button" onclick="save()">保存</button>
  </p>
  <div id="content-articles-markdownEditor" style="display: none;">
    <h1>编辑 power by pell</h1>
    <div id="editor" class="pell"></div>
    <div style="margin-top:20px;">
        <h3>Text output:</h3>
        <div id="text-output"></div>
    </div>
    <div style="margin-top:20px;">
        <h3>HTML output:</h3>
        <pre id="html-output"></pre>
    </div>
  </div>
  <div id="content-articles-markdown">
    <h2 id="16">第16讲 无穷级数</h2>
<h3 id="1">1. 函数的正弦级数与余弦级展开</h3>
<p>
<script type="math/tex; mode=display">
f(x)=\cfrac{a_0}{2}+\sum_{n=1}^\infty(a_n\cos nx+b_n\sin nx) \\[1ex]
a_n=\cfrac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos{nx}dx \\[1ex]
b_n=\cfrac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin{nx}dx
</script>
</p>
<h3 id="2">2. 数项级数</h3>
<p>
<script type="math/tex; mode=display">
\sum_{n=1}^\infty u_n
</script>
</p>
<p>判敛法<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\sum_{n=1}^\infty u_n收敛⟺&\lim_{n\to\infty}S_n存在⟺\{S_n\}有界 \\[1ex]
                        ⟹&\lim_{n\to\infty}u_n=0 \\[1ex]
\sum_{n=1}^\infty(u_{n+1}-u_n)收敛⟺&\lim_{n\to\infty}u_n存在
\end{split}\end{equation}
</script>
</p>
<h4 id="1_1">（1）正向级数</h4>
<h5 id="1_2">1、比较判别法</h5>
<p>
<script type="math/tex; mode=display">
\sum_{n=1}^\infty u_n,\ (u_n > 0)
</script>
</p>
<p>比较判别法，<strong>比较：设两个正项级数</strong><br />
<script type="math/tex; mode=display">
\sum_{n=1}^\infty u_n,\ (u_n > 0)，\sum_{n=1}^\infty v_n,\ (v_n > 0)
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
&u_n \le v_n \\[2ex]
若\sum_{n=1}^\infty v_n 收敛，&则\sum_{n=1}^\infty u_n 收敛 \\[1ex]
&若\sum_{n=1}^\infty u_n 发散，&则\sum_{n=1}^\infty v_n 发散
\end{split}\end{equation}
</script>
</p>
<p>比较判别法的极限形式<br />
<script type="math/tex; mode=display">
\lim_{n\to\infty}\cfrac{u_n}{v_n}=l
\begin{cases}
0,                 & u_n 是 v_n 高阶无穷小
\begin{cases}
\sum_{n=1}^\infty v_n收敛，&\sum_{n=1}^\infty u_n收敛 \\[1ex]
&\sum_{n=1}^\infty u_n发散，\sum_{n=1}^\infty v_n发散
\end{cases} \\[2ex]
0\lt c\lt +\infty, & u_n 是 v_n 同阶无穷小，\sum_{n=1}^\infty u_n，\sum_{n=1}^\infty v_n同敛散\\[2ex]
+\infty            & u_n 是 v_n 低阶无穷小
\begin{cases}
\sum_{n=1}^\infty v_n发散，&\sum_{n=1}^\infty u_n发散 \\[1ex]
&\sum_{n=1}^\infty u_n收敛，\sum_{n=1}^\infty v_n收敛
\end{cases}
\end{cases}
</script>
</p>
<blockquote class="content-quote">
<p>等比级数<br />
<script type="math/tex; mode=display">
\sum_{n=1}^\infty aq^{n-1}= \lim_{n\to\infty}\cfrac{a(1-q^n)}{1-q}
\begin{cases}
=\cfrac{a}{1-q}, & |q|\lt1 \\[2ex]
\text{发散}, & |q|\ge1
\end{cases}
</script>
</p>
<p>
<script type="math/tex">p</script> 级数<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
p\ 级数：
\sum_{n=1}^\infty \cfrac{1}{n^p}
&\begin{cases}
\text{收敛}, & p\gt1 \\[2ex]
\text{发散}, & p\le1
\end{cases} \\[2em]
广义\ p\ 级数：
\sum_{n=1}^\infty \cfrac{1}{n(\ln n)^p}
&\begin{cases}
\text{收敛}, & p\gt1 \\[2ex]
\text{发散}, & p\le1
\end{cases} \\[2em]
交错\ p\ 级数：
\sum_{n=1}^\infty (-1)^{n-1}\cfrac{1}{n^p}
&\begin{cases}
\text{绝对收敛}, & p\gt1 \\[2ex]
\text{条件收敛}, & 【\ 0\lt p\le1\ 】
\end{cases}
\end{split}\end{equation}
</script>
</p>
<p>反常积分<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
p\ 积分：
\int_a^{+\infty}\cfrac{1}{x^p}dx
&\begin{cases}
\text{收敛}, & p\gt1 \\[2ex]
\text{发散}, & p\le1
\end{cases} \\[2em]
广义\ p\ 积分：
\int_a^{+\infty}\cfrac{1}{x^\alpha(\ln x)^\beta}dx
&\begin{cases}
\text{收敛}, &\alpha\gt1\ 或\ \alpha=1,\beta\gt1 \\[2ex]
\text{发散}, &\alpha\lt1\ 或\ \alpha=1,\beta\le1 \\[2ex]
\end{cases} \\[2em]
瑕积分：
\int_0^1\cfrac{1}{x^p}dx
&\begin{cases}
\text{收敛}, & 【\ p\lt1\ 】 \\[2ex]
\text{发散}, & 【\ p\ge1\ 】
\end{cases} \\[2em]
\int_a^b\cfrac{1}{(x-a)^p}dx
&\begin{cases}
\text{收敛}, & 【\ q\lt1\ 】 \\[2ex]
\text{发散}, & 【\ q\ge1\ 】
\end{cases}
\end{split}\end{equation}
</script>
<br />
</p>
</blockquote>
<h5 id="2_1">2、比值判别法（达朗贝尔）</h5>
<p>
<script type="math/tex; mode=display">
\lim_{n\to\infty}\cfrac{u_{n+1}}{u_n}=\rho
\begin{cases}
\text{收敛}, & \rho\lt1 \\[2ex]
\text{发散}, & \rho\gt1 \\[2ex]
\text{失效}, & \rho=1
\end{cases}
</script>
</p>
<h5 id="3">3、根植判别式（柯西）</h5>
<p>
<script type="math/tex; mode=display">
\lim_{n\to\infty}\sqrt[n]{u_n}=\rho
\begin{cases}
\text{收敛}, & \rho\lt1 \\[2ex]
\text{发散}, & \rho\gt1 \\[2ex]
\text{失效}, & \rho=1
\end{cases}
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
比值判别法成立 &\Rightarrow 根值判别法成立 \\[2ex]
&\nLeftarrow
\end{split}\end{equation}
</script>
</p>
<h4 id="2_2">（2）交错级数</h4>
<p>
<script type="math/tex; mode=display">
\sum_{n=1}^\infty (-1)^{n-1}u_n,\ (u_n > 0)
</script>
</p>
<p>
<script type="math/tex; mode=display">
莱布尼兹判别法：\lim_{n\to\infty} u_n = 0\ 且\ u_n \ge u_{n+1}\Rightarrow 级数收敛
</script>
</p>
<h4 id="3_1">（3）任意级数</h4>
<p>
<script type="math/tex; mode=display">
\sum_{n=1}^\infty u_n
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\lim_{n\to\infty}|u_n| 收敛                           & \Rightarrow \lim_{n\to\infty}u_n 绝对收敛 \\[1em]
\lim_{n\to\infty}|u_n| 发散，\lim_{n\to\infty}u_n 收敛 & \Rightarrow \lim_{n\to\infty}u_n 条件收敛
\end{split}\end{equation}
</script>
</p>
<p>绝对收敛级数是收敛的，但收敛的级数不一定是绝对收敛级数。</p>
<h4 id="4">（4）条件收敛</h4>
<p>
<script type="math/tex; mode=display">
\sum u_n 收敛，\sum |u_n|发散，则该级数条件收敛
</script>
</p>
<h3 id="3_2">3. 幂级数</h3>
<p>
<script type="math/tex; mode=display">
\sum_{n=1}^\infty u_n \ \ 的幂级数形式：\sum_{n=0}^\infty a_n x^n
</script>
</p>
<h4 id="1_3">（1）收敛半径、收敛区间、收敛域的关系</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
&对于标准幂级数：\sum_{n=0}^\infty a_n x^n \\[2ex]
&收敛半径：R \\[2ex]
&收敛区间：(-R,R)\\[2ex]
&收敛域：(-R,R)+收敛区间端点的收敛性
\end{split}\end{equation}
</script>
</p>
<h4 id="2_3">（2）收敛半径</h4>
<h5 id="1-a_n-neq-0n012">1、不缺项幂级数 <script type="math/tex">a_n \neq 0,(n=0,1,2...)</script>
</h5>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\lim_{n\to\infty}\bigg|\cfrac{a_{n+1}}{a_n}\bigg| &= \rho \\[2ex]
\lim_{n\to\infty}\sqrt[n]{a_n} &= \rho \\[2em]
\sum_{n=0}^{\infty}a_nx^n \ \ 的收敛半径R &= 
\begin{cases}
\cfrac{1}{\rho}, & \rho \ne 0, +\infty\\[2ex]
+\infty,         & \rho = 0 \\[2ex]
0,               & \rho = +\infty
\end{cases}
\end{split}\end{equation}
</script>
</p>
<h5 id="2_4">2、缺项幂级数的收敛半径</h5>
<p>回归数项级数收敛域定义<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
(注意绝对值)\ \ \ \lim_{n\to\infty}\cfrac{|u_{n+1}(x)|}{|u_n(x)|} &= \rho \\[2ex]
\lim_{n\to\infty}\sqrt[n]{|u_n(x)|} &= \rho \\[2ex]
\end{split}\end{equation}
</script>
</p>
<h4 id="3_3">（3）阿贝尔定理</h4>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
&幂级数\sum_{n=0}^\infty a_nx^n在点 x=x_1(x_1\neq0)处收敛，对于|x|<|x_1|的x，幂级数绝对收敛 \\
&幂级数\sum_{n=0}^\infty a_nx^n在点 x=x_2(x_2\neq0)处发散，对于|x|>|x_2|的x，幂级数发散
\end{split}\end{equation}
</script>
</p>
<h3 id="4_1">4. 展开</h3>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
函数展开：f(x) &= \sum a_n x^n \\[1em]
积分展开：\int_a^b f(x)dx &= \sum a_n\cfrac{b^{n+1}-a^{n+1}}{n+1}\\[1em]
导数展开：\cfrac{df(x)}{dx} &= \sum na_n x^{n-1}
\end{split}\end{equation}
</script>
</p>
<h3 id="5-sx">5. 求和函数 <script type="math/tex">S(x)</script>
</h3>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
S(x)=\sum_{n=1}^\infty u_n(x)
\end{split}\end{equation}
</script>
</p>
<p>对于幂级数可以直接计算<br />
<script type="math/tex; mode=display">
S(x)=\cfrac{首项}{1-公比} \ \ \ (\pmb{\pmb{\pmb{\pmb{！！！}}}})
</script>
</p>
<h5 id="1_4">1、直接计算或带入泰勒级数</h5>
<h5 id="2_5">2、用先积后导或先导后积的方法</h5>
<ol>
<li>先积后导</li>
</ol>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\ \ \ \ \ \ S(x)&=\sum (an+b)x^{an} \\[2ex]
&=x\sum (an+b)x^{an-1} \\[2ex]
\int_0^x S_{tmp}(t)dt&=\int_0^x \sum (an+b)t^{an-1}dt \\[2ex]
&=\sum\int_0^x (an+b)t^{an-1}dt \\[2ex]
&=\sum (x^{an}+\cfrac{b}{an}x^{an}) \\[2ex]
&=\sum (x^a)^n+\cfrac{b}{a}\sum\cfrac{(x^a)^n}{n} \\[2ex]
S_{tmp}(x)&=(...)'\\[2ex]
S(x)&=xS_{tmp}(x)
\end{split}\end{equation}
</script>
</p>
<ol start="2">
<li>先导后积</li>
</ol>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\ \ \ \ \ \ S(x)&=\sum \cfrac{x^{an}}{an+b} \\[2ex]
&=x^{-b}\sum \cfrac{1}{an+b}x^{an+b}\\[2ex]
S'(x)
&=-bx^{-b-1}\sum \cfrac{1}{an+b}x^{an+b}+x^{-b}\sum x^{an+b-1} \\[2ex]
&=-bx^{-1}\sum \cfrac{1}{an+b}x^{an}+\sum x^{an-1} \\[2ex]
&=-bx^{-1}S(x)+\sum x^{an-1} \\[3ex]
(若\ b=0)\ \ \ \ \ \int_0^xS(t)dt&=\int_0^x... \\[2ex]
&=S(x)-S(0) \\[2ex]
(其他, 解微分方程) \ \ \ \ ...
\end{split}\end{equation}
</script>
</p>
<ol start="3">
<li>拆分</li>
</ol>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
\ \ \ \ \ \ S(x)&=\sum \cfrac{cn^2+dn+e}{an+b}x^{an}=\sum_{(1)}+\sum_{(2)}
\end{split}\end{equation}
</script>
</p>
<blockquote class="content-quote">
<p>例题：【2020第17题】设数列 <script type="math/tex">\{a_n\}</script> 满足 <script type="math/tex">a_1=1,(n+1)a_{n+1}=(n+\cfrac{1}{2})a_n</script>，证明：当 <script type="math/tex">|x|<1</script> 时，幂级数 <script type="math/tex">\sum_{n=1}^\infty a_nx^n</script> 收敛，并求其和函数 <script type="math/tex">S(x)</script>
</p>
<p>1、证明，当 <script type="math/tex">|x|<1</script> 时，幂级数 <script type="math/tex">\sum_{n=1}^\infty a_nx^n</script> 收敛<br />
<script type="math/tex; mode=display">
\cfrac{a_{n+1}}{a_n}=\cfrac{n+\cfrac{1}{2}}{n+1} < 1
</script>
<br />
又 <script type="math/tex">a_1=1</script>，则数列 <script type="math/tex">\{a_n\}</script> 单调递减，且 <script type="math/tex">0<a_n<1 </script>，<script type="math/tex">|a_nx^n|<|x^n|</script>
</p>
<p>当 <script type="math/tex">|x|<1</script> 时，幂级数 <script type="math/tex">\sum_{n=1}^\infty x^n</script> 绝对收敛，故 <script type="math/tex">\sum_{n=1}^\infty a_nx^n</script> 绝对收敛（绝对收敛 <script type="math/tex">\to</script> 收敛）<br />
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
S(x)&=\sum_{n=1}^\infty a_nx^n \\[1em]
S'(x)&=(\sum_{n=1}^\infty a_nx^n)'=\sum_{n=1}^\infty na_nx^{n-1} \\
&=\sum_{n=0}^\infty (n+1)a_{n+1}x^{n} \\
&=a_1+\sum_{n=1}^\infty (n+1)a_{n+1}x^{n} \\
&=a_1+\sum_{n=1}^\infty (n+\cfrac{1}{2})a_{n}x^{n} \\
&=a_1+\sum_{n=1}^\infty na_{n}x^{n}+\cfrac{1}{2}\sum_{n=1}^\infty a_{n}x^{n} \\
&=a_1+x\sum_{n=1}^\infty na_{n}x^{n-1}+\cfrac{1}{2}\sum_{n=1}^\infty a_{n}x^{n} \\
&=a_1+xS'(x)+\cfrac{1}{2}S(x) \\[1em]
\end{split}\end{equation}
</script>
<br />
解微分方程：<script type="math/tex">(1-x)S'(x)-\cfrac{1}{2}S(x)=1</script>，即 <script type="math/tex">S'(x)-\cfrac{1}{2(1-x)}S(x)=\cfrac{1}{1-x}</script>
<br />
<script type="math/tex; mode=display">
p(x)=-\cfrac{1}{2(1-x)}， q(x)=\cfrac{1}{1-x}
</script>
</p>
<p>
<script type="math/tex; mode=display">
\begin{equation}\begin{split}
S(x)&=e^{-\int p(x)dx}(\int e^{\int p(x)dx}q(x)dx+C) \\
&=e^{-\int (-\frac{1}{2(1-x)})dx}(\int e^{\int (-\frac{1}{2(1-x)})dx}(\frac{1}{1-x})dx+C) \\
&=e^{-\frac{1}{2}\ln(1-x)}(\int e^{\frac{1}{2}\ln(1-x)}(\frac{1}{1-x})dx+C) \\
&=(1-x)^{-\frac{1}{2}}(\int(1-x)^{-\frac{1}{2}}dx+C) \\
&=(1-x)^{-\frac{1}{2}}(-2(1-x)^{\frac{1}{2}}+C) \\
&=-2+\cfrac{C}{\sqrt{1-x}}\\[1em]
由于S(0)&=0，得到C=2 \\[1em]
S(x)&=-2+\frac{2}{\sqrt{1-x}}
\end{split}\end{equation}
</script>
</p>
</blockquote>
  </div>
</div>
 
    </div>
  </div>
  <div id="footer-background">
    <div id="footer">
      <div class="legal pure-g">
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-license"><a href="https://beian.miit.gov.cn/#/Integrated/index">浙ICP备2020038748号</a></p>
  </div>
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-links"><a href="https://github.com/zromyk">GitHub</a></p>
    <p class="legal-copyright">Copyright © 2021 Wei Zhou. 保留所有权利。</p>
  </div>
</div>
    </div>
  </div>
  <!-- <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> -->
  <script src="/style/html/jquery.min.js"></script>
  <script src='/style/article/latex/latest.js?config=TeX-MML-AM_CHTML'></script>
<!-- <script src="https://cdn.geogebra.org/apps/deployggb.js"></script> -->
<script src="/style/article/deployggb.js"></script>
<!-- <script src="https://apps.bdimg.com/libs/highlight.js/9.1.0/highlight.min.js"></script> -->
<script type="text/javascript">
  // 脚本：navigation 随鼠标移动自动变换宽度
  var element = document.getElementById("navigation"); // 获取要操作的元素
  var elementWidth = parseInt(getComputedStyle(element).width);
  var elementLeft = 0;
  var elementRight = 0;
  element.addEventListener('mouseenter', function (event) { // 添加鼠标按下事件的监听器
    elementLeft = element.getBoundingClientRect().left - 10;
    elementRight = element.getBoundingClientRect().left + elementWidth * 3;
    window.addEventListener('mousemove', resize); // 添加全局的鼠标移动事件的监听器
  });

  function resize(event) {
    var minWidth = elementWidth;
    var maxWidth = elementWidth * 2.5;
    // console.log(elementLeft, event.clientX, elementRight, event.clientX - elementLeft + elementWidth / 2);
    if (elementLeft <= event.clientX && event.clientX <= elementRight) {
      var width = event.clientX - elementLeft + elementWidth / 2;
      width = Math.min(width, maxWidth);
      width = Math.max(width, minWidth);
      element.style.width = width + 'px'; // 设置新的宽度样式属性
    }
    else {
      element.style.width = elementWidth + 'px'; // 设置新的宽度样式属性
      stopResize();
    }
  }

  function stopResize() {
    element.style.width = elementWidth + 'px'; // 设置新的宽度样式属性
    // console.log("stopResize", elementLeft, event.clientX, elementRight, event.clientX - elementLeft + elementWidth / 2);
    window.removeEventListener('mousemove', resize); // 移除鼠标移动事件的监听器
  }
</script>
<script src="/style/article/highlight/highlight.min.js"></script>
<script type="text/javascript">
  // 脚本：code语法高亮
  hljs.initHighlightingOnLoad();
</script>
<script>
  function animateByNav() {
    $("html").animate({
        scrollTop: ($(event.target.hash).offset().top - 52)
    }, 300);
  };
</script>
<script src="/style/article/pell-1.0.6/dist/pell.js"></script>
<script>
  // 脚本：自由编辑页面
  var editor = window.pell.init({
    element: document.getElementById('editor'),
    defaultParagraphSeparator: 'p',
    onChange: function(html) {
        document.getElementById('text-output').innerHTML = html
        document.getElementById('html-output').textContent = html
    }
  });

  function markdownEditor() {
    var articles = document.getElementById('content-articles-markdown');
    if (articles.getAttribute("contenteditable") == "true") {
        articles.setAttribute("contenteditable", "false");
        document.getElementById("content-articles-markdownEditor").style.display = "none"; //隐藏
        document.getElementById("button-markdownEditor").innerHTML = "启用编辑";
    } else {
        articles.setAttribute("contenteditable", "true");
        document.getElementById("content-articles-markdownEditor").style.display = ""; //显示
        document.getElementById("button-markdownEditor").innerHTML = "关闭编辑";
    }
  };

  function save() {
      window.alert("保存成功");
  };
</script>

</body>
</html>
